let list = value.list(&k)?;
output.cfgs.extend(list.iter().map(|v| v.0.clone()));
}
+ "rustc-env" => {
+ for (name, val) in value.table(&k)?.0 {
+ let val = val.string(name)?.0;
+ output.env.push((name.clone(), val.to_string()));
+ }
+ }
"warning" | "rerun-if-changed" => {
bail!("`{}` is not supported in build script overrides", k);
}
// been put there by one of the `build_scripts`) to the command provided.
fn add_custom_env(rustc: &mut ProcessBuilder,
build_state: &BuildMap,
- build_scripts: &BuildScripts,
+ _: &BuildScripts,
current_id: &PackageId) -> CargoResult<()> {
- for key in build_scripts.to_link.iter() {
- let output = build_state.get(key).chain_error(|| {
- internal(format!("couldn't find build state for {}/{:?}",
- key.0, key.1))
- })?;
- if key.0 == *current_id {
- for &(ref name, ref value) in output.env.iter() {
- rustc.env(name, value);
- }
+ let key = (current_id.clone(), Kind::Host);
+ if let Some(output) = build_state.get(&key) {
+ for &(ref name, ref value) in output.env.iter() {
+ rustc.env(name, value);
}
}
Ok(())
"#)
.file("src/main.rs", r#"
const FOO: &'static str = env!("FOO");
- fn main() {}
+ fn main() {
+ println!("{}", FOO);
+ }
"#)
.file("build.rs", r#"
fn main() {
"#);
assert_that(build.cargo_process("build").arg("-v"),
execs().with_status(0));
+ assert_that(build.cargo("run").arg("-v"),
+ execs().with_status(0).with_stdout("foo\n"));
}
#[test]